package com.example.reagent_management.ui.operatedialog.adapter

import android.annotation.SuppressLint
import androidx.recyclerview.widget.DiffUtil
import com.example.lib_base.adapter.BasePagingAdapter
import com.example.reagent_management.R
import com.example.reagent_management.room.entity.ReagentInformation

class ReagentInfoAdapter : BasePagingAdapter<ReagentInformation>(object : DiffUtil.ItemCallback<ReagentInformation>(){
    override fun areItemsTheSame(
        oldItem: ReagentInformation,
        newItem: ReagentInformation
    ): Boolean {
        return oldItem.reagent_id == newItem.reagent_id
    }

    @SuppressLint("DiffUtilEquals")
    override fun areContentsTheSame(
        oldItem: ReagentInformation,
        newItem: ReagentInformation
    ): Boolean {
      return  oldItem === newItem
    }

}) {
    override fun getItemLayout(position: Int): Int {
        return R.layout.item_reagent_info
    }

    override fun bindData(helper: ItemHelper, data: ReagentInformation?) {
        data?.let {
            with(helper){
//                setVisible(R.id.delete,true)
                setText(R.id.project_name,it.projectName)
                setText(R.id.reagent_name,it.reagentName)
                setText(R.id.type,it.reagentType)
                bindImgGlide(R.id.delete,R.drawable.ic_baseline_delete_forever_24)
            }
        }
    }

    override fun getClickViewId(): Array<Int>? {
        return Array(1) { R.id.delete }
    }
}